Class SparseMatrix
java.lang.Object
edu.claflin.finder.algo.clustering.struct.fast_greedy_struct.SparseMatrix
SparseMatrix is a sparse matrix with row format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int i, int j, double q) Add the given j index, q value pair to the ith tree and heapvoidaddHeap(int i, int j, double q) Add the given j index, q value pair to the ith heap.voidaddTree(int i, int j, double q) Add the given j index, q value pair to the ith tree.voidclearRow(int i) Clear the ith tree and heapget(int i, int j) get number at index or null if not set.getMax(int i) Get the maximum q value at row ivoidmergeTrees(int j, int i) Merge Trees j and i into j, summing values if the same column occurs.voidrebuildHeap(int j) Rebuild heap j with the tree jprivate voidremoveFromTree(int i, int j) introws()get the rows of the matrixvoidset(int i, int j, double q) Set the q value at the ith tree and heap's j column.voidsetHeap(int i, int j, double q) Set the value q and the ith heap's j column.voidsetTree(int i, int j, double q) Set value q and the ith tree's j column.toString()
-
Field Details
-
heaps
-
trees
-
rows
private int rows
-
-
Constructor Details
-
SparseMatrix
public SparseMatrix(int rows) empty sparse matrix with allocated number of rows- Parameters:
rows- the number of rows
-
-
Method Details
-
rows
public int rows()get the rows of the matrix- Returns:
- the number of rows in the matrix
-
add
public void add(int i, int j, double q) Add the given j index, q value pair to the ith tree and heap- Parameters:
i- the row to addj- the j indexq- the q value
-
addTree
public void addTree(int i, int j, double q) Add the given j index, q value pair to the ith tree.- Parameters:
i- the row to addj- the j indexq- the q value
-
addHeap
public void addHeap(int i, int j, double q) Add the given j index, q value pair to the ith heap.- Parameters:
i- the row to addj- the j indexq- the q value
-
get
get number at index or null if not set.- Parameters:
i- the row to searchj- the colum to search- Returns:
- the q value if it exists or null
-
setTree
public void setTree(int i, int j, double q) Set value q and the ith tree's j column. add it if it's not there.- Parameters:
i- the row to set inj- the column to set inq- the new q value
-
setHeap
public void setHeap(int i, int j, double q) Set the value q and the ith heap's j column. add it if it's not there.- Parameters:
i- the row to set inj- the column to set inq- the new q value
-
set
public void set(int i, int j, double q) Set the q value at the ith tree and heap's j column.- Parameters:
i- the row to set inj- the column to set inq- the new q value
-
removeFromTree
private void removeFromTree(int i, int j) -
getMax
Get the maximum q value at row i- Parameters:
i- the row to search in- Returns:
- the maximum q value
-
clearRow
public void clearRow(int i) Clear the ith tree and heap- Parameters:
i- the row to clear in
-
mergeTrees
public void mergeTrees(int j, int i) Merge Trees j and i into j, summing values if the same column occurs.- Parameters:
j- the tree to expandi- the tree that offers its Nodes
-
rebuildHeap
public void rebuildHeap(int j) Rebuild heap j with the tree j- Parameters:
j- the heap to rebuild
-
toString
-